Unverified Commit f2a295de authored by Shu Ding's avatar Shu Ding Committed by GitHub

Fix typo in TS plugin (#45279)

parent e8b208d1
...@@ -305,15 +305,15 @@ export function createTSPlugin(modules: { ...@@ -305,15 +305,15 @@ export function createTSPlugin(modules: {
) )
) { ) {
if (ts.isVariableDeclarationList(node.declarationList)) { if (ts.isVariableDeclarationList(node.declarationList)) {
for (const declarartion of node.declarationList.declarations) { for (const declaration of node.declarationList.declarations) {
if ( if (
declarartion.getFullStart() <= position && declaration.getFullStart() <= position &&
position <= position <=
declarartion.getFullStart() + declarartion.getFullWidth() declaration.getFullStart() + declaration.getFullWidth()
) { ) {
// `export const ... = ...` // `export const ... = ...`
const text = declarartion.name.getText() const text = declaration.name.getText()
callback(text, declarartion) callback(text, declaration)
} }
} }
} }
...@@ -369,13 +369,12 @@ export function createTSPlugin(modules: { ...@@ -369,13 +369,12 @@ export function createTSPlugin(modules: {
} }
// Auto completion for entry exported configs. // Auto completion for entry exported configs.
visitEntryConfig(fileName, position, (entryConfig, declarartion) => { visitEntryConfig(fileName, position, (entryConfig, declaration) => {
if (!API_DOCS[entryConfig]) { if (!API_DOCS[entryConfig]) {
if ( if (
declarartion.name.getFullStart() <= position && declaration.name.getFullStart() <= position &&
position <= position <=
declarartion.name.getFullStart() + declaration.name.getFullStart() + declaration.name.getFullWidth()
declarartion.name.getFullWidth()
) { ) {
prior.entries = [ prior.entries = [
...prior.entries, ...prior.entries,
...@@ -569,11 +568,11 @@ export function createTSPlugin(modules: { ...@@ -569,11 +568,11 @@ export function createTSPlugin(modules: {
} }
let overriden: ts.QuickInfo | undefined let overriden: ts.QuickInfo | undefined
visitEntryConfig(fileName, position, (entryConfig, declarartion) => { visitEntryConfig(fileName, position, (entryConfig, declaration) => {
if (!API_DOCS[entryConfig]) return if (!API_DOCS[entryConfig]) return
const name = declarartion.name const name = declaration.name
const value = declarartion.initializer const value = declaration.initializer
const docsLink = { const docsLink = {
kind: 'text', kind: 'text',
...@@ -712,8 +711,8 @@ export function createTSPlugin(modules: { ...@@ -712,8 +711,8 @@ export function createTSPlugin(modules: {
) { ) {
// Check if it has correct option exports // Check if it has correct option exports
if (ts.isVariableDeclarationList(node.declarationList)) { if (ts.isVariableDeclarationList(node.declarationList)) {
for (const declarartion of node.declarationList.declarations) { for (const declaration of node.declarationList.declarations) {
const name = declarartion.name const name = declaration.name
if (ts.isIdentifier(name)) { if (ts.isIdentifier(name)) {
if ( if (
!ALLOWED_EXPORTS.includes(name.text) && !ALLOWED_EXPORTS.includes(name.text) &&
...@@ -729,7 +728,7 @@ export function createTSPlugin(modules: { ...@@ -729,7 +728,7 @@ export function createTSPlugin(modules: {
}) })
} else if (API_DOCS[name.text]) { } else if (API_DOCS[name.text]) {
// Check if the value is valid // Check if the value is valid
const value = declarartion.initializer const value = declaration.initializer
if (value) { if (value) {
let displayedValue = '' let displayedValue = ''
...@@ -808,7 +807,7 @@ export function createTSPlugin(modules: { ...@@ -808,7 +807,7 @@ export function createTSPlugin(modules: {
} else if (name.text === LEGACY_CONFIG_EXPORT) { } else if (name.text === LEGACY_CONFIG_EXPORT) {
// export const config = { ... } // export const config = { ... }
// Error if using `amp: ...` // Error if using `amp: ...`
const value = declarartion.initializer const value = declaration.initializer
if (value && ts.isObjectLiteralExpression(value)) { if (value && ts.isObjectLiteralExpression(value)) {
for (const prop of value.properties) { for (const prop of value.properties) {
if ( if (
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment