@arcgis/lumina-compiler 5.2.0-next.2 → 5.2.0-next.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/context/index.d.ts +158 -296
- package/dist/context/types.d.ts +18 -34
- package/dist/defaultAssetsUrl.d.ts +6 -6
- package/dist/dependencies/discover.d.ts +43 -35
- package/dist/dependencies/updateLumina.d.ts +10 -11
- package/dist/docs/vsCodeCustomData/types.d.ts +5 -42
- package/dist/docs/webTypes/types.d.ts +5 -76
- package/dist/index.d.ts +20 -20
- package/dist/index.js +12 -8
- package/dist/jsxToLitHtml/config.d.ts +93 -121
- package/dist/options.d.ts +675 -0
- package/dist/puppeteerTesting/index.d.ts +18 -11
- package/dist/puppeteerTesting/index.js +104 -7
- package/dist/puppeteerTesting/puppeteer/element.d.ts +250 -217
- package/dist/puppeteerTesting/puppeteer/events.d.ts +15 -21
- package/dist/puppeteerTesting/puppeteer/page.d.ts +8 -5
- package/dist/puppeteerTesting/puppeteer/types.d.ts +130 -132
- package/dist/puppeteerTesting/vitest/matchers/index.d.ts +33 -30
- package/dist/testing/index.d.ts +4 -11
- package/dist/testing/mount.d.ts +113 -93
- package/dist/testing/wrapController.d.ts +5 -11
- package/dist/useLumina.d.ts +5 -2
- package/package.json +15 -7
- package/dist/context/logger.d.ts +0 -8
- package/dist/context/typeScript.d.ts +0 -6
- package/dist/context/utils.d.ts +0 -4
- package/dist/dependencies/arcgisCore.d.ts +0 -30
- package/dist/dependencies/index.d.ts +0 -12
- package/dist/dependencies/loaders.d.ts +0 -5
- package/dist/dependencies/lumina.d.ts +0 -3
- package/dist/dependencies/stencil.d.ts +0 -17
- package/dist/dependencies/testSetupFiles.d.ts +0 -13
- package/dist/dependencies/utils.d.ts +0 -15
- package/dist/docs/config.d.ts +0 -9
- package/dist/docs/index.d.ts +0 -10
- package/dist/docs/stencilDocsJson.d.ts +0 -130
- package/dist/docs/types.d.ts +0 -1
- package/dist/docs/vsCodeCustomData/index.d.ts +0 -16
- package/dist/docs/vsCodeCustomData/utils.d.ts +0 -3
- package/dist/docs/webTypes/description.d.ts +0 -2
- package/dist/docs/webTypes/index.d.ts +0 -19
- package/dist/docs/webTypes/utils.d.ts +0 -6
- package/dist/entrypoints/addNonLazyImports.d.ts +0 -13
- package/dist/entrypoints/config.d.ts +0 -17
- package/dist/entrypoints/dtsUtils.d.ts +0 -19
- package/dist/entrypoints/findUtils.d.ts +0 -6
- package/dist/entrypoints/handleComponentImports.d.ts +0 -13
- package/dist/entrypoints/resolveTagName.d.ts +0 -18
- package/dist/jsxToLitHtml/autoAddNothing.d.ts +0 -8
- package/dist/jsxToLitHtml/comments.d.ts +0 -19
- package/dist/jsxToLitHtml/convertProps.d.ts +0 -10
- package/dist/jsxToLitHtml/imports.d.ts +0 -27
- package/dist/jsxToLitHtml/importsConfig.d.ts +0 -17
- package/dist/jsxToLitHtml/index.d.ts +0 -20
- package/dist/jsxToLitHtml/inferPropType.d.ts +0 -40
- package/dist/jsxToLitHtml/insertRepeatCall.d.ts +0 -51
- package/dist/jsxToLitHtml/jsxVisitor.d.ts +0 -15
- package/dist/jsxToLitHtml/templateParts.d.ts +0 -17
- package/dist/jsxToLitHtml/throwOnImportingExternalized.d.ts +0 -10
- package/dist/jsxToLitHtml/types.d.ts +0 -74
- package/dist/jsxToLitHtml/utils.d.ts +0 -14
- package/dist/loader/css.d.ts +0 -20
- package/dist/loader/extractor.d.ts +0 -2
- package/dist/loader/index.d.ts +0 -21
- package/dist/loader/lazy.d.ts +0 -21
- package/dist/loader/storybookApiJson.d.ts +0 -6
- package/dist/plugins/buildCdn.d.ts +0 -73
- package/dist/plugins/buildWebApp.d.ts +0 -3
- package/dist/plugins/buildWrappers.d.ts +0 -4
- package/dist/plugins/configureVite.d.ts +0 -20
- package/dist/plugins/externalizeDependencies.d.ts +0 -30
- package/dist/plugins/handleDynamicAssets.d.ts +0 -8
- package/dist/plugins/handleStaticAssets.d.ts +0 -9
- package/dist/plugins/loadLitCss.d.ts +0 -127
- package/dist/plugins/printTotalBuildSize.d.ts +0 -7
- package/dist/plugins/provideAssets.d.ts +0 -35
- package/dist/plugins/setAssetsPath.d.ts +0 -10
- package/dist/plugins/updatePackageJson.d.ts +0 -14
- package/dist/publicTypes.d.ts +0 -653
- package/dist/puppeteerTesting/globalSetup.d.ts +0 -73
- package/dist/puppeteerTesting/injected.d.ts +0 -8
- package/dist/puppeteerTesting/puppeteer/browser.d.ts +0 -6
- package/dist/puppeteerTesting/vitest/matchers/attributes.d.ts +0 -4
- package/dist/puppeteerTesting/vitest/matchers/classList.d.ts +0 -4
- package/dist/puppeteerTesting/vitest/matchers/events.d.ts +0 -7
- package/dist/puppeteerTesting/vitest/matchers/text.d.ts +0 -2
- package/dist/puppeteerTesting/vitest/matchers/utils.d.ts +0 -1
- package/dist/puppeteerTesting/vitest/runner.d.ts +0 -19
- package/dist/puppeteerTesting/vitest/setupFile.d.ts +0 -1
- package/dist/puppeteerTesting/vitest/types.d.ts +0 -6
- package/dist/testing/failOnConsole.d.ts +0 -6
- package/dist/testing/setupFile.d.ts +0 -1
- package/dist/testing/snapshotSerializer.d.ts +0 -12
- package/dist/tests/utils.d.ts +0 -4
- package/dist/transformers/customElementDeclaration.d.ts +0 -2
- package/dist/transformers/index.d.ts +0 -20
- package/dist/transformers/injectRuntimeOptions.d.ts +0 -18
- package/dist/transformers/liftDecorators.d.ts +0 -21
- package/dist/transformers/members.d.ts +0 -10
- package/dist/transformers/property.d.ts +0 -10
- package/dist/transformers/propertyOptions.d.ts +0 -110
- package/dist/transformers/utils.d.ts +0 -9
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { TestProject } from 'vitest/node';
|
|
2
|
-
import { ConnectOptions } from 'puppeteer';
|
|
3
|
-
declare module "vitest" {
|
|
4
|
-
interface ProvidedContext {
|
|
5
|
-
isDevToolsEnabled?: boolean;
|
|
6
|
-
isHeadlessBrowser?: boolean;
|
|
7
|
-
devServerHtml?: string;
|
|
8
|
-
devServerUrl?: string;
|
|
9
|
-
puppeteerConnectOptions?: ConnectOptions;
|
|
10
|
-
puppeteerWaitForChangesDelay?: number;
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Global setup file for Vitest Puppeteer integration.
|
|
15
|
-
*
|
|
16
|
-
* This is run once, in the main thread, before any tests are run.
|
|
17
|
-
*
|
|
18
|
-
* We start browser via Puppeteer so that tests can render to it and interact
|
|
19
|
-
* with it.
|
|
20
|
-
*
|
|
21
|
-
* In the browser, we render the test suite. The browser sends requests for
|
|
22
|
-
* JavaScript files to the Vite dev server.
|
|
23
|
-
*
|
|
24
|
-
* We start that Vite dev server in this file too. It is separate from the
|
|
25
|
-
* Vite dev server started by Vitest.
|
|
26
|
-
*
|
|
27
|
-
* It has to be separate because Vitest's dev server resolves imports for the
|
|
28
|
-
* "node" import condition. If we instead tell Vitest to use browser export
|
|
29
|
-
* conditions, then Lit's "isServer" will be false both in browser and node.js,
|
|
30
|
-
* potentially breaking some components. While happy-dom is neat, it does match
|
|
31
|
-
* the actual browser API 100%. It is safer to run a separate Vite instance for
|
|
32
|
-
* Node.js (Vitest) and browser. This is a short-term issue anyway as we are
|
|
33
|
-
* looking to moving to Vitest browser mode feature, that would resolve this
|
|
34
|
-
* issue.
|
|
35
|
-
*
|
|
36
|
-
* Here is an example Vite configuration plugin that is needed if you wish to
|
|
37
|
-
* make Vitest's Vite instance somewhat usable directly by Playwright's browser:
|
|
38
|
-
* ```ts
|
|
39
|
-
* config: (config) => {
|
|
40
|
-
* const conditions = config.resolve?.conditions;
|
|
41
|
-
* // Remove "node" condition.
|
|
42
|
-
* // Can't do this imperatively as Vite's default configuration merging only
|
|
43
|
-
* // allows adding settings, not removing.
|
|
44
|
-
* if (conditions && conditions.includes("node")) {
|
|
45
|
-
* conditions.splice(conditions.indexOf("node"), 1);
|
|
46
|
-
* }
|
|
47
|
-
* return {
|
|
48
|
-
* server: {
|
|
49
|
-
* middlewareMode: false,
|
|
50
|
-
* },
|
|
51
|
-
* test: {
|
|
52
|
-
* api: true,
|
|
53
|
-
* environment: "happy-dom",
|
|
54
|
-
* },
|
|
55
|
-
* };
|
|
56
|
-
* },
|
|
57
|
-
*
|
|
58
|
-
* Vite's upcoming Environment API will make it possible to use a single dev
|
|
59
|
-
* server (https://github.com/vitejs/vite/pull/16089/files). However, we plan
|
|
60
|
-
* to provide Puppeteer integration only temporary to ease the Stencil
|
|
61
|
-
* migration, so optimizing it too much is not a goal.
|
|
62
|
-
*/
|
|
63
|
-
export declare function setup(context: TestProject): Promise<() => Promise<void>>;
|
|
64
|
-
export type PuppeteerViteGlobals = {
|
|
65
|
-
/**
|
|
66
|
-
* Helps lumina-compiler dev server know that is it running for Puppeteer
|
|
67
|
-
* browser.
|
|
68
|
-
*
|
|
69
|
-
* Not exposing this in global typings for usage in tests because
|
|
70
|
-
* `import.meta.env.MODE` should be used instead.
|
|
71
|
-
*/
|
|
72
|
-
__IS_IN_PUPPETEER__?: true;
|
|
73
|
-
};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { RawMatcherFn, SyncExpectationResult } from '@vitest/expect';
|
|
2
|
-
export declare const toHaveClass: RawMatcherFn;
|
|
3
|
-
export declare const toHaveClasses: (element: unknown, expectClassNames: string[]) => SyncExpectationResult;
|
|
4
|
-
export declare const toMatchClasses: RawMatcherFn;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { RawMatcherFn } from '@vitest/expect';
|
|
2
|
-
export declare const toHaveReceivedEvent: RawMatcherFn;
|
|
3
|
-
export declare const toHaveReceivedEventTimes: RawMatcherFn;
|
|
4
|
-
export declare const toHaveReceivedEventDetail: RawMatcherFn;
|
|
5
|
-
export declare const toHaveFirstReceivedEventDetail: RawMatcherFn;
|
|
6
|
-
export declare const toHaveLastReceivedEventDetail: RawMatcherFn;
|
|
7
|
-
export declare const toHaveNthReceivedEventDetail: RawMatcherFn;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function assertIsElement(element: unknown, matcherName: string): asserts element is Element;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { TestRunner } from 'vitest';
|
|
2
|
-
import { Page } from 'puppeteer';
|
|
3
|
-
import { Suite } from '@vitest/runner';
|
|
4
|
-
/**
|
|
5
|
-
* This has to be default export for Vitest to discover it
|
|
6
|
-
*
|
|
7
|
-
* @see https://github.com/vitest-dev/vitest/blob/699055eb93909287e1542fdfb99d97f2a38965ba/packages/vitest/src/runtime/runners/index.ts#L25
|
|
8
|
-
*/
|
|
9
|
-
export default class PuppeteerTestRunner extends TestRunner {
|
|
10
|
-
private _browser?;
|
|
11
|
-
private _pages;
|
|
12
|
-
private _pageCloseExpected;
|
|
13
|
-
private _browserClosePromise?;
|
|
14
|
-
constructor(...rest: ConstructorParameters<typeof TestRunner>);
|
|
15
|
-
createNewPage(): Promise<Page>;
|
|
16
|
-
private _connectBrowser;
|
|
17
|
-
private _closeOpenPages;
|
|
18
|
-
onAfterRunSuite(suite: Suite): Promise<void>;
|
|
19
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function setupPuppeteerTest(): void;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function setupLuminaTest(): void;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Adds a vitest serializer for Shadow DOM.
|
|
3
|
-
* You do not need to call this function directly - `@arcgis/lumina-compiler` will
|
|
4
|
-
* configure Vitest to use this serializer automatically.
|
|
5
|
-
*
|
|
6
|
-
* @example
|
|
7
|
-
* ```tsx
|
|
8
|
-
* const { el, component } = await mount("arcgis-test1");
|
|
9
|
-
* expect(el.shadowRoot).toMatchInlineSnapshot(`<p>1</p>`);
|
|
10
|
-
* ```
|
|
11
|
-
*/
|
|
12
|
-
export declare function addShadowDomSerializer(): void;
|
package/dist/tests/utils.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { Plugin } from 'vite';
|
|
2
|
-
import { CompilerContext } from '../context/index.ts';
|
|
3
|
-
/**
|
|
4
|
-
* A pipeline of transformers for .tsx files.
|
|
5
|
-
* Only .tsx files are touched as all transformations deal with components and
|
|
6
|
-
* components should be defined in .tsx files.
|
|
7
|
-
*
|
|
8
|
-
* Instead of having separate transform() vite plugins, and each plugin having
|
|
9
|
-
* to generate a source map (or forgetting to do so and breaking DX) and then
|
|
10
|
-
* having Vite merge those source maps (Vite's source map merging can loose
|
|
11
|
-
* precision), the pipeline is just a list of TypeScript transformers
|
|
12
|
-
* efficiently applied one after another.
|
|
13
|
-
*
|
|
14
|
-
* And at the end, TypeScript will generate the source map for us - it does it
|
|
15
|
-
* in a smart way - if we re-use the original typescript node during
|
|
16
|
-
* transformation, then that node has original position information attached to
|
|
17
|
-
* it - thus, even if transformer moves things around a lot, TypeScript can
|
|
18
|
-
* still create a great source map.
|
|
19
|
-
*/
|
|
20
|
-
export declare const componentTransformPipeline: (context: CompilerContext) => Plugin;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { CompilerContext } from '../context/index.ts';
|
|
2
|
-
import { Plugin } from 'vite';
|
|
3
|
-
/**
|
|
4
|
-
* Update src/runtime.ts in the component package based on the options specified
|
|
5
|
-
* in the Lumina config. This is done so that all configuration is isolated to
|
|
6
|
-
* the single vite.config.ts file, rather than spread over several files.
|
|
7
|
-
*/
|
|
8
|
-
export declare const injectRuntimeOptions: (context: CompilerContext) => Plugin;
|
|
9
|
-
/**
|
|
10
|
-
* Add to chunks/runtime.js import statement for the global CSS file.
|
|
11
|
-
* This way CSS is injected automatically, simplifying get started instructions.
|
|
12
|
-
* We also inject CSS imports for Lumina dependencies this package uses - this
|
|
13
|
-
* is needed to ensure CSS is loaded in correct order - this does not cause
|
|
14
|
-
* duplicate CSS bundling.
|
|
15
|
-
*
|
|
16
|
-
* Research notes: https://devtopia.esri.com/WebGIS/arcgis-web-components/discussions/1824#discussioncomment-12625
|
|
17
|
-
*/
|
|
18
|
-
export declare function getGlobalCssImport(context: CompilerContext): string;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { default as ts } from 'typescript';
|
|
2
|
-
export type LiftedDecorators = Map<string, ts.ObjectLiteralExpression>;
|
|
3
|
-
/**
|
|
4
|
-
* Using decorators in a file means shipping TypeScript's decorator polyfill.
|
|
5
|
-
* Plus, the decorator polyfill is meant to be generic and so adds more code
|
|
6
|
-
* than needed.
|
|
7
|
-
*
|
|
8
|
-
* Fortunately, Lit supports a static "properties" property (mainly for
|
|
9
|
-
* non-TypeScript users) that can be used to define properties in a more
|
|
10
|
-
* build size efficient way, without the need for `@property()` or `@state()`
|
|
11
|
-
* decorators.
|
|
12
|
-
*
|
|
13
|
-
* @remarks
|
|
14
|
-
* Without this, map-components CDN build is 398kb.
|
|
15
|
-
* With lifted decorator, it is 364kb (34kb smaller).
|
|
16
|
-
* AND, with compact property options it's 354kb (7kb smaller).
|
|
17
|
-
*
|
|
18
|
-
* For comparison, map-components Stencil CDN build is 370kb (and they
|
|
19
|
-
* lift all decorators too).
|
|
20
|
-
*/
|
|
21
|
-
export declare function liftDecorators(members: readonly ts.ClassElement[], liftedDecorators: LiftedDecorators, minifyFlags: boolean): readonly ts.ClassElement[];
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { FileTransformer } from '../publicTypes.ts';
|
|
2
|
-
/**
|
|
3
|
-
* - Remove `@Method()` decorators from the code. `@Method()` decorators are
|
|
4
|
-
* only needed for the docs extraction.
|
|
5
|
-
* - Add `{ type: Number }` or `{ type: Boolean }` to `@property()` where
|
|
6
|
-
* necessary
|
|
7
|
-
* - Replace `@property()` decorators with `static properties = {}` to reduce
|
|
8
|
-
* bundle size.
|
|
9
|
-
*/
|
|
10
|
-
export declare const transformMembers: FileTransformer;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { default as ts } from 'typescript';
|
|
2
|
-
import { FileTransformContext } from '../publicTypes.ts';
|
|
3
|
-
import { LiftedDecorators } from './liftDecorators.ts';
|
|
4
|
-
import { ApiCustomElementDeclaration } from '@arcgis/api-extractor/apiJson';
|
|
5
|
-
export declare function transformProperty(context: FileTransformContext, component: ApiCustomElementDeclaration | undefined, property: ts.AccessorDeclaration | ts.PropertyDeclaration, className: string | undefined, sourceFile: ts.SourceFile, liftedDecorators: LiftedDecorators): ts.ClassElement;
|
|
6
|
-
export type ParsedPropertyDecorator = {
|
|
7
|
-
decorator: ts.Decorator;
|
|
8
|
-
callExpression: ts.CallExpression;
|
|
9
|
-
options: ts.ObjectLiteralExpression | undefined;
|
|
10
|
-
};
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
import { default as ts } from 'typescript';
|
|
2
|
-
import { ParsedPropertyDecorator } from './property.ts';
|
|
3
|
-
import { ApiCustomElementField } from '@arcgis/api-extractor/apiJson';
|
|
4
|
-
/**
|
|
5
|
-
* In Stencil, the compiler uses type checking to determine if the inferred
|
|
6
|
-
* property type is number or boolean, and if so, would make sure to cast the
|
|
7
|
-
* string attribute value to number or boolean. Even in development mode type
|
|
8
|
-
* checking is used for that - which is not ideal as it slows down the dev server.
|
|
9
|
-
*
|
|
10
|
-
* That is why in Lumina we are no doing type checking at all (not even
|
|
11
|
-
* creating a TypeScript program) in the dev server. That of course puts some
|
|
12
|
-
* constraints on us.
|
|
13
|
-
*
|
|
14
|
-
* In Lit, since there is no compiler, Lit relies on the `{type: Number}` or
|
|
15
|
-
* `{type: Boolean}` property being passed to the `@property` decorator to
|
|
16
|
-
* determine if the property should be cast.
|
|
17
|
-
*
|
|
18
|
-
* Looking at all usages of number and boolean properties in Calcite and
|
|
19
|
-
* map-components, I see a few patterns:
|
|
20
|
-
*
|
|
21
|
-
* - In Calcite:
|
|
22
|
-
*
|
|
23
|
-
* - all boolean properties either explicitly have "false" as a default value,
|
|
24
|
-
* or explicitly have `boolean` type in TypeScript - in this case the AST
|
|
25
|
-
* contains enough information for lumina-compiler to insert `{type: Boolean}`
|
|
26
|
-
* in the code at build-time.
|
|
27
|
-
* - most number properties either have `number` type in TypeScript or numeric
|
|
28
|
-
* default value. This however is not always the case as there are a few
|
|
29
|
-
* exceptions:
|
|
30
|
-
*
|
|
31
|
-
* - calcite-action-group.columns: uses `Columns` number enum as it's type
|
|
32
|
-
* - calcite-block.headingLevel: uses `HeadingLevel` number enum as it's
|
|
33
|
-
* type
|
|
34
|
-
* - calcite-pagination.maxItems, calcite-popover.offsetDistance and
|
|
35
|
-
* calcite-tooltip.offsetDistance: use a const variable of numeric type as
|
|
36
|
-
* their default value
|
|
37
|
-
*
|
|
38
|
-
* These cases can't be inferred from the AST alone
|
|
39
|
-
*
|
|
40
|
-
* - In Map Components:
|
|
41
|
-
*
|
|
42
|
-
* - here the story is complicated by the fact that we use the following
|
|
43
|
-
* Controllers syntax in a lot of places:
|
|
44
|
-
*
|
|
45
|
-
* ```tsx
|
|
46
|
-
* \@Prop() hideCreateFeaturesSection = this.widget.visibleElements.createFeaturesSection;
|
|
47
|
-
* ```
|
|
48
|
-
*
|
|
49
|
-
* In the above, the type is boolean, but we can't know that from the AST.
|
|
50
|
-
*
|
|
51
|
-
* Since we can use the type checker during build, I am considering solving the
|
|
52
|
-
* issue like this:
|
|
53
|
-
*
|
|
54
|
-
* - both in serve and build mode, look at the AST to see if we can trivially
|
|
55
|
-
* infer whether the property type is number or boolean
|
|
56
|
-
* - in build mode:
|
|
57
|
-
* - if has a custom converter specified, don't do anything
|
|
58
|
-
* - else, if trivially inferred that property is boolean and number:
|
|
59
|
-
* - if has explicit type annotation:
|
|
60
|
-
* - if type annotation is of type number or boolean:
|
|
61
|
-
* - edit the source code to automatically remove the useless type
|
|
62
|
-
* annotation, and add a small log message to notify dev about what
|
|
63
|
-
* happened
|
|
64
|
-
* - warn about mismatching type annotation
|
|
65
|
-
* - add {type:Number} or {type:Boolean} to the .js output code, not source
|
|
66
|
-
* code
|
|
67
|
-
* - else, use the type checker, with an algorithm similar to Stencil to
|
|
68
|
-
* detect if property type is number or boolean
|
|
69
|
-
* - if detected that property type is not number or boolean
|
|
70
|
-
* - don't do anything
|
|
71
|
-
* - else, if property type is number or boolean
|
|
72
|
-
* - edit the source file to automatically add the type annotation
|
|
73
|
-
* and add a small log message to notify dev about what happened
|
|
74
|
-
* - add `{type:Number}` or `{type:Boolean}` to the .js output code
|
|
75
|
-
* - else, don't do anything
|
|
76
|
-
* - in dev mode:
|
|
77
|
-
* - if type or converter is explicitly present
|
|
78
|
-
* - don't do anything
|
|
79
|
-
* - if inferred that property type is number or boolean
|
|
80
|
-
* - add `{type:Number}` or `{type:Boolean}` to the .js output code, not
|
|
81
|
-
* source code
|
|
82
|
-
*
|
|
83
|
-
* The benefits of the above:
|
|
84
|
-
*
|
|
85
|
-
* - dev build is fast as no type checking is happening
|
|
86
|
-
* - source code is clean as type annotations are not present, unless ambiguous
|
|
87
|
-
* - in ambiguous cases, the source code has an explicit annotation, which
|
|
88
|
-
* ensures the serve mode has the same behavior as build for all properties
|
|
89
|
-
* - ambiguous newly added properties in serve mode won't yet have an explicit
|
|
90
|
-
* type annotation, but that is okay as ambiguous number/boolean properties
|
|
91
|
-
* are not that common, and in development mode properties are often set as
|
|
92
|
-
* JavaScript properties rather than HTML attributes, thus bypassing the
|
|
93
|
-
* need to cast the property
|
|
94
|
-
* - when converting a codebase from Stencil to Lit (either manually or using
|
|
95
|
-
* the codemod), the type annotations in ambiguous places would be inserted
|
|
96
|
-
* automatically if not yet present
|
|
97
|
-
* - when converting wrapped map-components widget to native, most usages of a
|
|
98
|
-
* code style like this will be removed, to be replaced with unambiguous
|
|
99
|
-
* `false` default value:
|
|
100
|
-
*
|
|
101
|
-
* ```tsx
|
|
102
|
-
* \@Prop() hideCreateFeaturesSection = this.widget.visibleElements.createFeaturesSection;
|
|
103
|
-
* ```
|
|
104
|
-
*
|
|
105
|
-
* In such cases, the above algorithm will automatically remove the now
|
|
106
|
-
* useless type annotation.
|
|
107
|
-
*
|
|
108
|
-
* See also https://github.com/runem/lit-analyzer/blob/master/packages/lit-analyzer/src/lib/rules/no-incompatible-property-type.ts
|
|
109
|
-
*/
|
|
110
|
-
export declare function transformPropertyOptions(decorator: ParsedPropertyDecorator, sourceFile: ts.SourceFile, apiProperty: ApiCustomElementField): ts.ObjectLiteralExpression | undefined;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { default as ts } from 'typescript';
|
|
2
|
-
import { FileTransformContext, FileTransformer } from '../publicTypes.ts';
|
|
3
|
-
import { CompilerContext } from '../context/index.ts';
|
|
4
|
-
/**
|
|
5
|
-
* Run a chain of transformers on a TypeScript .tsx or .d.ts file and return
|
|
6
|
-
* the resulting source file
|
|
7
|
-
*/
|
|
8
|
-
export declare function runTransformers(context: CompilerContext, transformationContext: ts.TransformationContext, sourceFile: ts.SourceFile, transformers: readonly FileTransformer[]): ts.SourceFile;
|
|
9
|
-
export declare function removeComments(node: ts.Node, context: FileTransformContext): void;
|