Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: TypeScript 5.7 support #2585

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"lint": "prettier --check ."
},
"dependencies": {
"typescript": "~5.6.3"
"typescript": "^5.7.2"
},
"devDependencies": {
"cross-env": "^7.0.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/language-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"prettier-plugin-svelte": "^3.3.0",
"svelte": "^4.2.19",
"svelte2tsx": "workspace:~",
"typescript": "~5.6.3",
"typescript": "^5.7.2",
"typescript-auto-import-cache": "^0.3.5",
"vscode-css-languageservice": "~6.3.0",
"vscode-html-languageservice": "~5.3.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -772,7 +772,11 @@ export class CompletionsProviderImpl implements CompletionsProvider<CompletionRe
}

const isNewIdentifierLocation = response.isNewIdentifierLocation;
let defaultCommitCharacters = response.defaultCommitCharacters;
// TypeScript 5.7+ reused the same array for different completions
let defaultCommitCharacters = response.defaultCommitCharacters
? Array.from(response.defaultCommitCharacters)
: undefined;

if (!isNewIdentifierLocation) {
// This actually always exists although it's optional in the type, at least in ts 5.6,
// so our commit characters are mostly fallback for older ts versions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
$: c.abc = a.abc = ao.abc = '';
</script>

<CustomElement />
<Accessors />
<AccessorsAndOption />
<CustomElement bind:this={c} />
<Accessors bind:this={a} />
<AccessorsAndOption bind:this={ao} />
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
<script>
let anyType;

async function load() {
anyType = (await (await fetch('')).json());
}
load();
</script>

{#each anyType as anyEntry}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
},
"severity": 1,
"source": "ts",
"message": "Type 'boolean' is not assignable to type 'never'.",
"message": "Type 'true' is not assignable to type 'never'.",
"code": 2322,
"tags": []
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
},
"severity": 1,
"source": "ts",
"message": "Type 'boolean' is not assignable to type 'never'.",
"message": "Type 'true' is not assignable to type 'never'.",
"code": 2322,
"tags": []
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[
{
"range": {
"start": { "line": 21, "character": 19 },
"end": { "line": 21, "character": 26 }
"start": { "line": 25, "character": 19 },
"end": { "line": 25, "character": 26 }
},
"severity": 1,
"source": "ts",
Expand All @@ -12,8 +12,8 @@
},
{
"range": {
"start": { "line": 21, "character": 40 },
"end": { "line": 21, "character": 47 }
"start": { "line": 25, "character": 40 },
"end": { "line": 25, "character": 47 }
},
"severity": 1,
"source": "ts",
Expand All @@ -23,8 +23,8 @@
},
{
"range": {
"start": { "line": 23, "character": 11 },
"end": { "line": 23, "character": 20 }
"start": { "line": 27, "character": 11 },
"end": { "line": 27, "character": 20 }
},
"severity": 1,
"source": "ts",
Expand All @@ -34,8 +34,8 @@
},
{
"range": {
"start": { "line": 25, "character": 11 },
"end": { "line": 25, "character": 18 }
"start": { "line": 29, "character": 11 },
"end": { "line": 29, "character": 18 }
},
"severity": 1,
"source": "ts",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<script lang="ts">
let value: string | number | boolean;

function handleClick() {
value = 'hello';
}
</script>

<!-- valid -->
Expand All @@ -9,7 +13,7 @@

<div>{valueStr.substring(0)}{valueStr2.substring(0)}</div>

<button on:click={() => {valueStr.substring(0)}}></button>
<button on:click={() => {valueStr.substring(0) && handleClick()}}></button>
{:else if typeof value === 'number'}
{value.toFixed()}
{/if}
Expand All @@ -24,4 +28,4 @@
{value.substring(0)}
{:else}
{value.toFixed()}
{/if}
{/if}
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
[
{
"range": { "start": { "line": 3, "character": 4 }, "end": { "line": 3, "character": 6 } },
"range": { "start": { "line": 5, "character": 4 }, "end": { "line": 5, "character": 6 } },
"severity": 1,
"source": "ts",
"message": "Variable 'hi' is used before being assigned.",
"code": 2454,
"tags": []
},
{
"range": { "start": { "line": 7, "character": 4 }, "end": { "line": 7, "character": 7 } },
"severity": 1,
"source": "ts",
"message": "Variable 'hi3' is used before being assigned.",
"code": 2454,
"tags": []
},
{
"range": { "start": { "line": 16, "character": 1 }, "end": { "line": 16, "character": 3 } },
"severity": 1,
"source": "ts",
"message": "Variable 'hi' is used before being assigned.",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
<script lang="ts">
let hi: string
export let hi2: string;
let hi3: string;

hi.toString();
hi2.toString();
hi3.toString();

$: hi3.toString();

function setHi3() {
hi3 = 'hi3';
}
setHi3();
</script>
{hi}
{hi}
{hi2}
{hi3}
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
"value": "MouseEvent",
"location": {
"range": {
"start": { "line": 15340, "character": 10 },
"end": { "line": 15340, "character": 20 }
"start": { "line": 16152, "character": 10 },
"end": { "line": 16152, "character": 20 }
},
"uri": "<node_modules>/typescript/lib/lib.dom.d.ts"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"value": "MouseEvent",
"location": {
"range": {
"start": { "line": 15340, "character": 10 },
"end": { "line": 15340, "character": 20 }
"start": { "line": 16152, "character": 10 },
"end": { "line": 16152, "character": 20 }
},
"uri": "<node_modules>/typescript/lib/lib.dom.d.ts"
}
Expand All @@ -21,8 +21,8 @@
"value": "EventTarget",
"location": {
"range": {
"start": { "line": 8284, "character": 10 },
"end": { "line": 8284, "character": 21 }
"start": { "line": 8694, "character": 10 },
"end": { "line": 8694, "character": 21 }
},
"uri": "<node_modules>/typescript/lib/lib.dom.d.ts"
}
Expand All @@ -32,8 +32,8 @@
"value": "HTMLButtonElement",
"location": {
"range": {
"start": { "line": 9721, "character": 10 },
"end": { "line": 9721, "character": 27 }
"start": { "line": 10145, "character": 10 },
"end": { "line": 10145, "character": 27 }
},
"uri": "<node_modules>/typescript/lib/lib.dom.d.ts"
}
Expand Down
2 changes: 1 addition & 1 deletion packages/svelte-check/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"rollup-plugin-copy": "^3.4.0",
"svelte": "^4.2.19",
"svelte-language-server": "workspace:*",
"typescript": "~5.6.3",
"typescript": "^5.7.2",
"vscode-languageserver": "8.0.2",
"vscode-languageserver-protocol": "3.17.2",
"vscode-languageserver-types": "3.17.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/svelte-vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,7 @@
"@types/vscode": "^1.67",
"js-yaml": "^3.14.0",
"tslib": "^2.4.0",
"typescript": "~5.6.3",
"typescript": "^5.7.2",
"vscode-tmgrammar-test": "^0.0.11"
},
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/svelte2tsx/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"svelte": "~4.2.19",
"tiny-glob": "^0.2.6",
"tslib": "^2.4.0",
"typescript": "~5.6.3"
"typescript": "^5.7.2"
},
"peerDependencies": {
"svelte": "^3.55 || ^4.0.0-next.0 || ^4.0 || ^5.0.0-next.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/typescript-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"license": "MIT",
"devDependencies": {
"@types/node": "^18.0.0",
"typescript": "~5.6.3",
"typescript": "^5.7.2",
"svelte": "^4.2.19"
},
"dependencies": {
Expand Down
Loading