Open HoldYourWaffle opened 11 months ago
Hi @HoldYourWaffle,
Thanks for this question. I'll reach out to the product team and get an answer for you.
Hi @HoldYourWaffle
The version of TypeScript used by Office Scripts is currently 4.0.3. We are currently looking at a way to update the *Script versions without risking breaking existing scripts. Given that this upgrade path is still undefined in the product, that we have a layer of additional TS restrictions for Office Scripts (some of which that limit the IntelliSense), and that the nature of Excel platforms and update channels complicates this whole conversation, we’re hesitant to document specific implementation details at this time. When this active discussion resolved, we’ll update the documentation accordingly.
The version of TypeScript used by Office Scripts is currently 4.0.3. We are currently looking at a way to update the *Script versions without risking breaking existing scripts. Given that this upgrade path is still undefined in the product, that we have a layer of additional TS restrictions for Office Scripts (some of which that limit the IntelliSense), and that the nature of Excel platforms and update channels complicates this whole conversation, we’re hesitant to document specific implementation details at this time. When this active discussion resolved, we’ll update the documentation accordingly.
There are now lots of useful APIs available at runtime but missing TS types. In my smallish ~400-line script, I've had to resort to multiple hacks to get around this:
// let x = distances.at(-1)!
let x: number = distances['at'](-1)
// const obj = Object.fromEntries(...)
const obj: Record<string, string> = Object['fromEntries'](...)
// const settled = await Promise.allSettled(...)
const settled: ({ status: 'fulfilled', value: QueryResultData } | { status: 'rejected', reason: unknown })[] = await
Promise['allSettled'](...)
// const result = results.findLastIndex(...)
const result = results['findLastIndex' as string as 'findIndex'](...)
// const locale = new Intl.Locale(...)
const locale: { language?: string, script?: string, region?: string } = new Intl['Locale'](...)
It'd be really nice to have access to the latest APIs in TS as well as at runtime, especially given the lack of any
support.
If the upgrade path is complicated by backward compatibility concerns, is there any possibility of relaxing the type checking requirements? I.e. scripts with type checking errors still run, they just show squiggly lines in the editor (and maybe warnings in the console), much like running TypeScript code in Deno without the --check
flag.
Edit: Also, maybe relaxing type checking requirements could unblock https://github.com/OfficeDev/office-scripts-docs-reference/issues/318? 🤞
Article URL
Office Scripts Code Editor environment
Issue
The article listed above mentions that Office Scripts are written in TypeScript, but it doesn't mention which version. Based on some trial and error I'm fairly confident that (as of Excel version 2310) it's TypeScript v3.7, but I'd love to see some official documentation on this :)