Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitdca7170

Browse files
authored
Fix bad JSON syntax in tests, use JSON.parse first for perf (microsoft#61901)
1 parent47ca599 commitdca7170

File tree

70 files changed

+209
-146
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+209
-146
lines changed

‎src/compiler/utilities.ts‎

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7715,9 +7715,18 @@ export function base64decode(host: { base64decode?(input: string): string; } | u
77157715
exportfunctionreadJsonOrUndefined(path:string,hostOrText:{readFile(fileName:string):string|undefined;}|string):object|undefined{
77167716
constjsonText=isString(hostOrText) ?hostOrText :hostOrText.readFile(path);
77177717
if(!jsonText)returnundefined;
7718-
// gracefully handle if readFile fails or returns not JSON
7719-
constresult=parseConfigFileTextToJson(path,jsonText);
7720-
return!result.error ?result.config :undefined;
7718+
// Try strictly parsing first, then fall back to our (slower)
7719+
// parser that is resilient to comments/trailing commas.
7720+
// package.json files should never have these, but we
7721+
// have no way to communicate these issues in the first place.
7722+
letresult=tryParseJson(jsonText);
7723+
if(result===undefined){
7724+
constlooseResult=parseConfigFileTextToJson(path,jsonText);
7725+
if(!looseResult.error){
7726+
result=looseResult.config;
7727+
}
7728+
}
7729+
returnresult;
77217730
}
77227731

77237732
/**@internal */

‎tests/baselines/reference/conditionalExportsResolutionFallback(moduleresolution=node16).errors.txt‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ error TS5110: Option 'module' must be set to 'Node16' when option 'moduleResolut
1010
".": {
1111
"import": "./dist/index.mjs",
1212
"require": "./dist/index.js",
13-
"types": "./dist/index.d.ts",
13+
"types": "./dist/index.d.ts"
1414
}
1515
}
1616
}
@@ -26,4 +26,5 @@ error TS5110: Option 'module' must be set to 'Node16' when option 'moduleResolut
2626
// Should be an untyped resolution to dep/dist/index.mjs,
2727
// but the first search is only for TS files, and when
2828
// there's no dist/index.d.mts, it continues looking for
29-
// matching conditions and resolves via `types`.
29+
// matching conditions and resolves via `types`.
30+

‎tests/baselines/reference/conditionalExportsResolutionFallback(moduleresolution=nodenext).errors.txt‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ error TS5110: Option 'module' must be set to 'NodeNext' when option 'moduleResol
1010
".": {
1111
"import": "./dist/index.mjs",
1212
"require": "./dist/index.js",
13-
"types": "./dist/index.d.ts",
13+
"types": "./dist/index.d.ts"
1414
}
1515
}
1616
}
@@ -26,4 +26,5 @@ error TS5110: Option 'module' must be set to 'NodeNext' when option 'moduleResol
2626
// Should be an untyped resolution to dep/dist/index.mjs,
2727
// but the first search is only for TS files, and when
2828
// there's no dist/index.d.mts, it continues looking for
29-
// matching conditions and resolves via `types`.
29+
// matching conditions and resolves via `types`.
30+

‎tests/baselines/reference/nodeModulesAllowJsConditionalPackageExports(module=node16).errors.txt‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,12 +126,13 @@ node_modules/inner/index.d.ts(2,13): error TS2303: Circular definition of import
126126
"./types": {
127127
"types": {
128128
"import": "./index.d.mts",
129-
"require": "./index.d.cts",
129+
"require": "./index.d.cts"
130130
},
131131
"node": {
132132
"import": "./index.mjs",
133133
"require": "./index.cjs"
134134
}
135135
}
136136
}
137-
}
137+
}
138+

‎tests/baselines/reference/nodeModulesAllowJsConditionalPackageExports(module=node16).js‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,15 +112,16 @@ export const cjsSource = true;
112112
"./types":{
113113
"types":{
114114
"import":"./index.d.mts",
115-
"require":"./index.d.cts",
115+
"require":"./index.d.cts"
116116
},
117117
"node":{
118118
"import":"./index.mjs",
119119
"require":"./index.cjs"
120120
}
121121
}
122122
}
123-
}
123+
}
124+
124125

125126
//// [index.mjs]
126127
// esm format file

‎tests/baselines/reference/nodeModulesAllowJsConditionalPackageExports(module=node18).errors.txt‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,12 +126,13 @@ node_modules/inner/index.d.ts(2,13): error TS2303: Circular definition of import
126126
"./types": {
127127
"types": {
128128
"import": "./index.d.mts",
129-
"require": "./index.d.cts",
129+
"require": "./index.d.cts"
130130
},
131131
"node": {
132132
"import": "./index.mjs",
133133
"require": "./index.cjs"
134134
}
135135
}
136136
}
137-
}
137+
}
138+

‎tests/baselines/reference/nodeModulesAllowJsConditionalPackageExports(module=node18).js‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,15 +112,16 @@ export const cjsSource = true;
112112
"./types":{
113113
"types":{
114114
"import":"./index.d.mts",
115-
"require":"./index.d.cts",
115+
"require":"./index.d.cts"
116116
},
117117
"node":{
118118
"import":"./index.mjs",
119119
"require":"./index.cjs"
120120
}
121121
}
122122
}
123-
}
123+
}
124+
124125

125126
//// [index.mjs]
126127
// esm format file

‎tests/baselines/reference/nodeModulesAllowJsConditionalPackageExports(module=node20).errors.txt‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,13 @@ node_modules/inner/index.d.ts(2,13): error TS2303: Circular definition of import
120120
"./types": {
121121
"types": {
122122
"import": "./index.d.mts",
123-
"require": "./index.d.cts",
123+
"require": "./index.d.cts"
124124
},
125125
"node": {
126126
"import": "./index.mjs",
127127
"require": "./index.cjs"
128128
}
129129
}
130130
}
131-
}
131+
}
132+

‎tests/baselines/reference/nodeModulesAllowJsConditionalPackageExports(module=node20).js‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,15 +112,16 @@ export const cjsSource = true;
112112
"./types":{
113113
"types":{
114114
"import":"./index.d.mts",
115-
"require":"./index.d.cts",
115+
"require":"./index.d.cts"
116116
},
117117
"node":{
118118
"import":"./index.mjs",
119119
"require":"./index.cjs"
120120
}
121121
}
122122
}
123-
}
123+
}
124+
124125

125126
//// [index.mjs]
126127
// esm format file

‎tests/baselines/reference/nodeModulesAllowJsConditionalPackageExports(module=nodenext).errors.txt‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,13 @@ node_modules/inner/index.d.ts(2,13): error TS2303: Circular definition of import
120120
"./types": {
121121
"types": {
122122
"import": "./index.d.mts",
123-
"require": "./index.d.cts",
123+
"require": "./index.d.cts"
124124
},
125125
"node": {
126126
"import": "./index.mjs",
127127
"require": "./index.cjs"
128128
}
129129
}
130130
}
131-
}
131+
}
132+

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp