diff --git a/.yarn/sdks/typescript/lib/tsserver.js b/.yarn/sdks/typescript/lib/tsserver.js index 71e35cf61194..b46100699e46 100644 --- a/.yarn/sdks/typescript/lib/tsserver.js +++ b/.yarn/sdks/typescript/lib/tsserver.js @@ -143,8 +143,9 @@ const moduleWrapper = tsserver => { let hostInfo = `unknown`; Object.assign(Session.prototype, { - onMessage(/** @type {string} */ message) { - const parsedMessage = JSON.parse(message) + onMessage(/** @type {string | object} */ message) { + const isStringMessage = typeof message === 'string'; + const parsedMessage = isStringMessage ? JSON.parse(message) : message; if ( parsedMessage != null && @@ -158,9 +159,14 @@ const moduleWrapper = tsserver => { } } - return originalOnMessage.call(this, JSON.stringify(parsedMessage, (key, value) => { - return typeof value === `string` ? fromEditorPath(value) : value; - })); + const processedMessageJSON = JSON.stringify(parsedMessage, (key, value) => { + return typeof value === 'string' ? fromEditorPath(value) : value; + }); + + return originalOnMessage.call( + this, + isStringMessage ? processedMessageJSON : JSON.parse(processedMessageJSON) + ); }, send(/** @type {any} */ msg) { diff --git a/.yarn/sdks/typescript/lib/tsserverlibrary.js b/.yarn/sdks/typescript/lib/tsserverlibrary.js index 7a2d65ea2206..73a026534a02 100644 --- a/.yarn/sdks/typescript/lib/tsserverlibrary.js +++ b/.yarn/sdks/typescript/lib/tsserverlibrary.js @@ -143,8 +143,9 @@ const moduleWrapper = tsserver => { let hostInfo = `unknown`; Object.assign(Session.prototype, { - onMessage(/** @type {string} */ message) { - const parsedMessage = JSON.parse(message) + onMessage(/** @type {string | object} */ message) { + const isStringMessage = typeof message === 'string'; + const parsedMessage = isStringMessage ? JSON.parse(message) : message; if ( parsedMessage != null && @@ -158,9 +159,14 @@ const moduleWrapper = tsserver => { } } - return originalOnMessage.call(this, JSON.stringify(parsedMessage, (key, value) => { - return typeof value === `string` ? fromEditorPath(value) : value; - })); + const processedMessageJSON = JSON.stringify(parsedMessage, (key, value) => { + return typeof value === 'string' ? fromEditorPath(value) : value; + }); + + return originalOnMessage.call( + this, + isStringMessage ? processedMessageJSON : JSON.parse(processedMessageJSON) + ); }, send(/** @type {any} */ msg) { diff --git a/.yarn/sdks/typescript/package.json b/.yarn/sdks/typescript/package.json index a5e90ed6d640..acb9eba787f2 100644 --- a/.yarn/sdks/typescript/package.json +++ b/.yarn/sdks/typescript/package.json @@ -1,6 +1,6 @@ { "name": "typescript", - "version": "4.4.2-sdk", + "version": "4.5.2-sdk", "main": "./lib/typescript.js", "type": "commonjs" } diff --git a/.yarn/versions/dd3df2e2.yml b/.yarn/versions/dd3df2e2.yml new file mode 100644 index 000000000000..49cfdd45ad88 --- /dev/null +++ b/.yarn/versions/dd3df2e2.yml @@ -0,0 +1,2 @@ +releases: + "@yarnpkg/sdks": patch diff --git a/packages/yarnpkg-sdks/sources/sdks/base.ts b/packages/yarnpkg-sdks/sources/sdks/base.ts index 5cb15c2bd61e..4c510e14027e 100644 --- a/packages/yarnpkg-sdks/sources/sdks/base.ts +++ b/packages/yarnpkg-sdks/sources/sdks/base.ts @@ -170,8 +170,9 @@ export const generateTypescriptBaseWrapper: GenerateBaseWrapper = async (pnpApi: let hostInfo = \`unknown\`; Object.assign(Session.prototype, { - onMessage(/** @type {string} */ message) { - const parsedMessage = JSON.parse(message) + onMessage(/** @type {string | object} */ message) { + const isStringMessage = typeof message === 'string'; + const parsedMessage = isStringMessage ? JSON.parse(message) : message; if ( parsedMessage != null && @@ -185,9 +186,14 @@ export const generateTypescriptBaseWrapper: GenerateBaseWrapper = async (pnpApi: } } - return originalOnMessage.call(this, JSON.stringify(parsedMessage, (key, value) => { - return typeof value === \`string\` ? fromEditorPath(value) : value; - })); + const processedMessageJSON = JSON.stringify(parsedMessage, (key, value) => { + return typeof value === 'string' ? fromEditorPath(value) : value; + }); + + return originalOnMessage.call( + this, + isStringMessage ? processedMessageJSON : JSON.parse(processedMessageJSON) + ); }, send(/** @type {any} */ msg) {