Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(fix) better backwards compatibility (#1640)
for new transformation #1352 This adds additional types to - incorporate custom element definitions into the new transformation - override instead of merge type definitions - allow easy SVGAttributes enhancement in the new trasnformation
- Loading branch information
1 parent
513f935
commit 37599b9
Showing
7 changed files
with
482 additions
and
7 deletions.
There are no files selected for viewing
112 changes: 112 additions & 0 deletions
112
...e-server/test/plugins/typescript/features/diagnostics/fixtures/custom-types/expected.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
[ | ||
{ | ||
"range": { | ||
"start": { "line": 12, "character": 19 }, | ||
"end": { "line": 12, "character": 20 } | ||
}, | ||
"severity": 4, | ||
"source": "ts", | ||
"message": "Parameter 'e' implicitly has an 'any' type, but a better type may be inferred from usage.", | ||
"code": 7044, | ||
"tags": [] | ||
}, | ||
{ | ||
"range": { | ||
"start": { "line": 21, "character": 19 }, | ||
"end": { "line": 21, "character": 20 } | ||
}, | ||
"severity": 4, | ||
"source": "ts", | ||
"message": "Parameter 'e' implicitly has an 'any' type, but a better type may be inferred from usage.", | ||
"code": 7044, | ||
"tags": [] | ||
}, | ||
{ | ||
"range": { | ||
"start": { "line": 11, "character": 5 }, | ||
"end": { "line": 11, "character": 12 } | ||
}, | ||
"severity": 1, | ||
"source": "ts", | ||
"message": "Type '{ owntype: string; }' is not assignable to type 'HTMLProps<HTMLDivElement>'.\n Property 'owntype' does not exist on type 'HTMLProps<HTMLDivElement>'.", | ||
"code": 2322, | ||
"tags": [] | ||
}, | ||
{ | ||
"range": { | ||
"start": { "line": 12, "character": 5 }, | ||
"end": { "line": 12, "character": 16 } | ||
}, | ||
"severity": 1, | ||
"source": "ts", | ||
"message": "Type '{ onownclick: (e: any) => any; }' is not assignable to type 'HTMLProps<HTMLDivElement>'.\n Property 'onownclick' does not exist on type 'HTMLProps<HTMLDivElement>'. Did you mean 'onclick'?", | ||
"code": 2322, | ||
"tags": [] | ||
}, | ||
{ | ||
"range": { | ||
"start": { "line": 19, "character": 5 }, | ||
"end": { "line": 19, "character": 12 } | ||
}, | ||
"severity": 1, | ||
"source": "ts", | ||
"message": "Type '{ owntype: boolean; }' is not assignable to type 'HTMLProps<HTMLDivElement>'.\n Property 'owntype' does not exist on type 'HTMLProps<HTMLDivElement>'.", | ||
"code": 2322, | ||
"tags": [] | ||
}, | ||
{ | ||
"range": { | ||
"start": { "line": 20, "character": 5 }, | ||
"end": { "line": 20, "character": 19 } | ||
}, | ||
"severity": 1, | ||
"source": "ts", | ||
"message": "Type 'boolean' is not assignable to type 'string'.", | ||
"code": 2322, | ||
"tags": [] | ||
}, | ||
{ | ||
"range": { | ||
"start": { "line": 21, "character": 5 }, | ||
"end": { "line": 21, "character": 16 } | ||
}, | ||
"severity": 1, | ||
"source": "ts", | ||
"message": "Type '{ onownclick: (e: any) => any; }' is not assignable to type 'HTMLProps<HTMLDivElement>'.\n Property 'onownclick' does not exist on type 'HTMLProps<HTMLDivElement>'. Did you mean 'onclick'?", | ||
"code": 2322, | ||
"tags": [] | ||
}, | ||
{ | ||
"range": { | ||
"start": { "line": 22, "character": 41 }, | ||
"end": { "line": 22, "character": 46 } | ||
}, | ||
"severity": 1, | ||
"source": "ts", | ||
"message": "Property 'wrong' does not exist on type '{ foo: string; }'.", | ||
"code": 2339, | ||
"tags": [] | ||
}, | ||
{ | ||
"range": { | ||
"start": { "line": 24, "character": 22 }, | ||
"end": { "line": 24, "character": 31 } | ||
}, | ||
"severity": 1, | ||
"source": "ts", | ||
"message": "Type 'boolean' is not assignable to type 'string'.", | ||
"code": 2322, | ||
"tags": [] | ||
}, | ||
{ | ||
"range": { | ||
"start": { "line": 25, "character": 22 }, | ||
"end": { "line": 25, "character": 32 } | ||
}, | ||
"severity": 1, | ||
"source": "ts", | ||
"message": "Type '{ doesnexist: string; }' is not assignable to type '{ attribute?: string; }'.\n Property 'doesnexist' does not exist on type '{ attribute?: string; }'.", | ||
"code": 2322, | ||
"tags": [] | ||
} | ||
] |
90 changes: 90 additions & 0 deletions
90
...server/test/plugins/typescript/features/diagnostics/fixtures/custom-types/expectedv2.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
[ | ||
{ | ||
"range": { | ||
"start": { "line": 15, "character": 13 }, | ||
"end": { "line": 15, "character": 22 } | ||
}, | ||
"severity": 1, | ||
"source": "ts", | ||
"message": "Type 'boolean' is not assignable to type 'string'.", | ||
"code": 2322, | ||
"tags": [] | ||
}, | ||
{ | ||
"range": { | ||
"start": { "line": 16, "character": 13 }, | ||
"end": { "line": 16, "character": 30 } | ||
}, | ||
"severity": 1, | ||
"source": "ts", | ||
"message": "Argument of type '{ doesnexist: string; }' is not assignable to parameter of type '{ attribute?: string; }'.\n Object literal may only specify known properties, and '\"doesnexist\"' does not exist in type '{ attribute?: string; }'.", | ||
"code": 2345, | ||
"tags": [] | ||
}, | ||
{ | ||
"range": { | ||
"start": { "line": 19, "character": 5 }, | ||
"end": { "line": 19, "character": 12 } | ||
}, | ||
"severity": 1, | ||
"source": "ts", | ||
"message": "Type 'boolean' is not assignable to type 'string'.", | ||
"code": 2322, | ||
"tags": [] | ||
}, | ||
{ | ||
"range": { | ||
"start": { "line": 20, "character": 5 }, | ||
"end": { "line": 20, "character": 19 } | ||
}, | ||
"severity": 1, | ||
"source": "ts", | ||
"message": "Type 'boolean' is not assignable to type 'string'.", | ||
"code": 2322, | ||
"tags": [] | ||
}, | ||
{ | ||
"range": { | ||
"start": { "line": 21, "character": 34 }, | ||
"end": { "line": 21, "character": 39 } | ||
}, | ||
"severity": 1, | ||
"source": "ts", | ||
"message": "Property 'wrong' does not exist on type '{ foo: string; }'.", | ||
"code": 2339, | ||
"tags": [] | ||
}, | ||
{ | ||
"range": { | ||
"start": { "line": 22, "character": 41 }, | ||
"end": { "line": 22, "character": 46 } | ||
}, | ||
"severity": 1, | ||
"source": "ts", | ||
"message": "Property 'wrong' does not exist on type '{ foo: string; }'.", | ||
"code": 2339, | ||
"tags": [] | ||
}, | ||
{ | ||
"range": { | ||
"start": { "line": 24, "character": 22 }, | ||
"end": { "line": 24, "character": 31 } | ||
}, | ||
"severity": 1, | ||
"source": "ts", | ||
"message": "Type 'boolean' is not assignable to type 'string'.", | ||
"code": 2322, | ||
"tags": [] | ||
}, | ||
{ | ||
"range": { | ||
"start": { "line": 25, "character": 22 }, | ||
"end": { "line": 25, "character": 39 } | ||
}, | ||
"severity": 1, | ||
"source": "ts", | ||
"message": "Argument of type '{ doesnexist: string; }' is not assignable to parameter of type '{ attribute?: string; }'.\n Object literal may only specify known properties, and '\"doesnexist\"' does not exist in type '{ attribute?: string; }'.", | ||
"code": 2345, | ||
"tags": [] | ||
} | ||
] |
26 changes: 26 additions & 0 deletions
26
...ge-server/test/plugins/typescript/features/diagnostics/fixtures/custom-types/input.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<script lang="ts"></script> | ||
|
||
<!-- valid for both --> | ||
<div owntypefromold="foo" /> | ||
<div on:ownclickfromold={(e) => e.detail.foo} /> | ||
|
||
<own-element attribute="foo" /> | ||
|
||
<own-element-from-old attribute="foo" /> | ||
|
||
<!-- valid for new, invalid for old --> | ||
<div owntype="foo" /> | ||
<div on:ownclick={(e) => e.detail.foo} /> | ||
|
||
<!-- valid for old, invalid for new --> | ||
<own-element attribute={false} /> | ||
<own-element doesnexist="wrong" /> | ||
|
||
<!-- invalid --> | ||
<div owntype={false} /> | ||
<div owntypefromold={false} /> | ||
<div on:ownclick={(e) => e.detail.wrong} /> | ||
<div on:ownclickfromold={(e) => e.detail.wrong} /> | ||
|
||
<own-element-from-old attribute={false} /> | ||
<own-element-from-old doesnexist="wrong" /> |
24 changes: 24 additions & 0 deletions
24
...plugins/typescript/features/diagnostics/fixtures/custom-types/svelte-ambient-typings.d.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* eslint-disable */ | ||
declare namespace svelte.JSX { | ||
interface HTMLAttributes { | ||
owntypefromold?: string; | ||
onownclickfromold?: (event: CustomEvent<{ foo: string }>) => void; | ||
} | ||
interface IntrinsicElements { | ||
'own-element-from-old': { | ||
attribute?: string; | ||
}; | ||
} | ||
} | ||
|
||
declare namespace svelteHTML { | ||
interface HTMLAttributes { | ||
owntype?: string; | ||
'on:ownclick'?: (event: CustomEvent<{ foo: string }>) => void; | ||
} | ||
interface IntrinsicElements { | ||
'own-element': { | ||
attribute?: string; | ||
}; | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
...e-server/test/plugins/typescript/features/diagnostics/fixtures/custom-types/tsconfig.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"compilerOptions": { | ||
/** | ||
This is actually not needed, but makes the tests faster | ||
because TS does not look up other types. | ||
*/ | ||
"types": ["svelte"] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.